function f_stylePhoneUp(){
	var obj = document.getElementById("stylePhoneUp");
	var top, browser;

	if(obj != null){
		browser = navigator.appName;
		if(browser.toLowerCase() == "netscape"){
			top = parseInt(obj.style.top);
			if (top == 0 || top == "NaN" || top == null || obj.style.top == "undefined" || obj.style.top == ""){
				obj.style.top = 143 + "px";
				top = parseInt(obj.style.top);
			}

			if (top != 0){
				if(top < 10){
					obj.style.top = 0 + "px";
					obj.style.display = "block";
				}else{
					obj.style.top = top - 10 + "px";
					obj.style.display = "block";
					setTimeout("f_stylePhoneUp()", 5);
				}
			}else{
				obj.style.display = "block";
			}
		}else{
			if (obj.style.top == "" || obj.style.top == "0px" || obj.style.top == "undefined"){
				obj.style.top = "143px";
			}

			if(obj.style.top != "0px;"){
				top = obj.style.top.toString();
				top = parseInt(top.substring(0, top.indexOf("px")));

				if(top < 10){
					obj.style.top = "0px";
					obj.style.display = "block";
				}else{
					obj.style.top = top - 10 + "px";
					obj.style.display = "block";
					setTimeout("f_stylePhoneUp()", 5);
				}
			}else{
				obj.style.display = "block";
			}
		}
	}
}

function f_stylePhoneDown(){
	var obj = document.getElementById("stylePhoneUp");
	var top, browser;

	if(obj != null){
		browser = navigator.appName;
		if(browser.toLowerCase() == "netscape"){
			top = parseInt(obj.style.top);
			if (top == 143 || top == "NaN" || top == null || obj.style.top == "undefined" || obj.style.top == ""){
				obj.style.top = 0 + "px";
				top = parseInt(obj.style.top);
			}

			if (top != 143){
				if(top > 130){
					obj.style.top = 143 + "px";
					obj.style.display = "block";
				}else{
					obj.style.top = top + 10 + "px";
					obj.style.display = "block";
					setTimeout("f_stylePhoneDown()", 5);
				}
			}else{
				obj.style.display = "block";
			}
		}else{
			if (obj.style.top == "" || obj.style.top == "143px" || obj.style.top == "undefined"){
				obj.style.top = "0px";
			}

			if(obj.style.top != "143px;"){
				top = obj.style.top.toString();
				top = parseInt(top.substring(0, top.indexOf("px")));

				if(top > 130){
					obj.style.top = "143px";
					obj.style.display = "block";
				}else{
					obj.style.top = top + 10 + "px";
					obj.style.display = "block";
					setTimeout("f_stylePhoneDown()", 5);
				}
			}else{
				obj.style.display = "block";
			}
		}
	}
}

var lastScrollY = 0;
var winH = 0

function f_compareBoxFirstLocator(){
	var obj = document.getElementById("compareBox");
	var browser, top;

	if(obj != null){
		browser = navigator.appName;

		if(browser.toLowerCase() == "netscape"){
			top = parseInt(obj.style.top);
			if (top == 0 || top == "NaN" || top == null || obj.style.top == "undefined" || obj.style.top == ""){
				obj.style.top = (window.innerHeight - 46) + "px";
			}
			winH = window.innerHeight - 46;
		}else{
			if (obj.style.top == "" || obj.style.top == "0px" || obj.style.top == "undefined"){
				obj.style.top = (document.documentElement.clientHeight - 46) + "px";
			}
			winH = document.documentElement.clientHeight - 46;
		}

		window.setInterval("f_compareBoxLocatorScroll()",1);
	}
}

function f_compareBoxLocatorScroll(){
	var obj = document.getElementById("compareBox");
	var browser, top, diffY, percent;

	if(obj != null){
		browser = navigator.appName;

		if(browser.toLowerCase() == "netscape"){
			//top = parseInt(obj.style.top);
			top = window.innerHeight - 46;
			diffY = self.pageYOffset;
		}else{
			//top = obj.style.top.toString();
			//top = parseInt(top.substring(0, top.indexOf("px")));
			top = document.documentElement.clientHeight - 46;
			diffY = document.documentElement.scrollTop; 
		}

		obj.style.top = (top + diffY) + "px";

		/*
		if(diffY != lastScrollY) {
			percent = .1 * (diffY - lastScrollY);

			if(percent > 0){
				percent = Math.ceil(percent);
				top = Math.ceil(top);
			}else{
				percent = Math.floor(percent);
				top = Math.floor(top);
			}
			obj.style.top = (top + percent) + "px";
			lastScrollY = lastScrollY + percent;
		}
		*/
	}
}

var actionUp;

function f_phoneCompareUp(){
	var obj = document.getElementById("compareBoxUp");
	var browser, top;

	if(obj != null){
		browser = navigator.appName;

		if(browser.toLowerCase() == "netscape"){
			top = parseInt(obj.style.top);
			if (top == 0 || top == "NaN" || top == null || obj.style.top == "undefined" || obj.style.top == ""){
				obj.style.top = 46 + "px";
				top = parseInt(obj.style.top);
			}
			
			if(top > -120){
				obj.style.top = top -10 + "px";
				obj.style.display = "block";
				setTimeout("f_phoneCompareUp()", 5);
			}else{
				obj.style.top = -124 + "px";
				obj.style.display = "block";
				window.clearInterval(actionUp);
				actionUp = window.setInterval("f_compareAuto()", 5000);
			}

		}else{
			top = obj.style.top.toString();
			top = parseInt(top.substring(0, top.indexOf("px")));

			if (obj.style.top == "" || obj.style.top == "0px" || obj.style.top == "undefined"){
				obj.style.top = 46 + "px";
				top = obj.style.top.toString();
				top = parseInt(top.substring(0, top.indexOf("px")));
			}

			if(top > -120){
				obj.style.top = top -10 + "px";
				obj.style.display = "block";
				setTimeout("f_phoneCompareUp()", 5);
			}else{
				obj.style.top = -124 + "px";
				obj.style.display = "block";
				window.clearInterval(actionUp);
				actionUp = window.setInterval("f_compareAuto()", 1500);
			}
		}
	}
}

function f_phoneCompareDown(){
	var obj = document.getElementById("compareBoxUp");
	var browser, top;

	if(obj != null){
		browser = navigator.appName;

		if(browser.toLowerCase() == "netscape"){
			top = parseInt(obj.style.top);
			if (top == 0 || top == "NaN" || top == null || obj.style.top == "undefined" || obj.style.top == ""){
				obj.style.top = -122 + "px";
				top = parseInt(obj.style.top);
			}

			if(top == 38){
				obj.style.top = 48 + "px";
				obj.style.display = "none";
			}else if(top < 40){
				obj.style.top = top +10 + "px";
				obj.style.display = "block";
				setTimeout("f_phoneCompareDown()", 5);
			}else{
				obj.style.display = "none";
			}
		}else{
			top = obj.style.top.toString();
			top = parseInt(top.substring(0, top.indexOf("px")));

			if (obj.style.top == "" || obj.style.top == "0px" || obj.style.top == "undefined"){
				obj.style.top = -122 + "px";
				top = obj.style.top.toString();
				top = parseInt(top.substring(0, top.indexOf("px")));
			}

			if(top == 36){
				obj.style.top = 46 + "px";
				obj.style.display = "none";
			}else if(top < 40){
				obj.style.top = top +10 + "px";
				obj.style.display = "block";
				setTimeout("f_phoneCompareDown()", 5);
			}else{
				obj.style.display = "none";
			}
		}
		window.clearInterval(actionUp);
	}
}

var nowImg = 1;

function f_subImgChange(num){
	var obj = document.getElementById("phoneDetailPic");
	var obj1 = document.getElementById("thumbPic" + num);

	if (obj != null && obj1 != null){
		obj.src = obj1.src;
		nowImg = num;
	}
}

function f_subImgMove(mode){
	var max, i;
	var obj, obj1;

	obj = document.getElementById("phoneDetailPic");

	for (i = 1; i < 11; i++){
		obj1 = document.getElementById("thumbPic" + i);
		if(obj1 == null){
			max = i - 1;
			i = 20;
		}
	}

	if(mode == "n"){
		if((nowImg + 1) > max){
			obj1 = document.getElementById("thumbPic1");
			obj.src = obj1.src;
			nowImg = 1;
		}else{
			obj1 = document.getElementById("thumbPic" + (nowImg + 1));
			obj.src = obj1.src;
			nowImg = nowImg + 1;
		}
	}else{
		if((nowImg - 1) < 1){
			obj1 = document.getElementById("thumbPic" + max);
			obj.src = obj1.src;
			nowImg = max;
		}else{
			obj1 = document.getElementById("thumbPic" + (nowImg - 1));
			obj.src = obj1.src;
			nowImg = nowImg - 1;
		}
	}
}

var productNO, productNM, productModel, productImg, productLink;
var dragLayer, dragYN, isCompare, compareText, downObj;
dragYN = false;
isCompare = "";
productNO = "";
productNM = "";
productModel = "";
productImg = "";
productLink = "";
compareText = "";

function f_addProduct(){
	var pNO, pNM, pModel, pImg, pLink;
	var compareProduct, arr1, i, setString, save;

	if (isCompare == "compare"){
		save = true;
		pNO = productNO;
		pNM = productNM;
		pModel = productModel;
		pImg = productImg;
		pLink = productLink;

		productNO = "";
		productNM = "";
		productModel = "";
		productImg = "";
		productLink = "";
		isCompare = "";

		setString = pNO + "^^" + pNM + "^^" + pModel + "^^" + pImg + "^^" + pLink;
		if (setString != "^^^^^^^^"){
			compareProduct = compareText;

			if (compareProduct != "" && compareProduct != "undefined" && compareProduct != null){
				arr1 = compareProduct.split("-&-");
				for (i = 0; i < arr1.length; i++){
					if(arr1[i] != ""){
						if(arr1[i] == setString){
							save = false;
							i = arr1.length;
						}
					}
				}
			}

			if(save == true){
				if (compareProduct != ""){
					setString = compareProduct + "-&-" + setString;
				}
				//document.cookie = "compareProduct=" + escape( setString ) + "; path=/; domain=" + document.domain + ";";
				compareText = setString;
				f_displayCompare();
				f_phoneCompareUp();
			}
		}
		//f_phoneCompareDown();
		//dragLayer = document.getElementById("dragLayer");
		//dragLayer.style.display = "none";
	}else{
		dragYN = false;
		dragLayer = document.getElementById("dragLayer");
		dragLayer.style.display = "none";
		productNO = "";
		productNM = "";
		productModel = "";
		productImg = "";
		productLink = "";
		isCompare = "";
	}
}

function f_displayCompare(){
	var compareProduct, arr1, i, arr2, j;
	var s, obj, idx, setString, html, img;

	compareProduct = compareText;
	idx = 1;
	img = new Image();
	setString = "";
	if (compareProduct != "" && compareProduct != "undefined" && compareProduct != null){
		arr1 = compareProduct.split("-&-");
		s = 0;
		if (arr1.length > 3){
			s = 1;
		}
		document.frmCompare.goods[0].value = "";
		document.frmCompare.goods[1].value = "";
		document.frmCompare.goods[2].value = "";
		for (i = s; i < arr1.length; i++){
			if(arr1[i] != "" && arr1[i] != "undefined"){
				arr2 = arr1[i].split("^^");
				if(arr2[1] != "undefined"){
					img.src = arr2[3];

					html = "<span id=\"compModel0\">" + arr2[1] +  "</span> <a href=\"javascript:f_deleteCompare(" + (idx -1) + ");\"><IMG SRC=\"/web/images/common/compare/btn_x.gif\" ALT=\"x\"></a>";
					obj = document.getElementById("compareBoxDown" + idx);
					obj.innerHTML = html;

					obj = document.getElementById("compareBoxUpText" + idx);
					obj.innerHTML = html;

					html = "<DL>";					
					html += "<DT><A HREF=javascript:f_phoneDetail('" + arr2[0] + "','" +  arr2[1] +  "')><img src=\"" + arr2[3] + "\" width=80 height=80 alt=\"" + arr2[2] + "\"></A>";					
				
					//html += "<DD class=\"txt3\"><span id=\"compModel0\"><A HREF=\"" + arr2[4] + "\">more </A><IMG SRC=\"/web/images/common/compare/more_a.gif\" ALT=\"\"></span>";
					html += "</DL>";

					obj = document.getElementById("compareBoxUp" + idx);
					obj.innerHTML = html;

					document.frmCompare.goods[(idx -1)].value = arr2[0];
					idx++;
					setString += arr1[i] + "-&-";
				}
			}
		}
		setString = setString.substring(0, setString.length - 3);
		//document.cookie = "compareProduct=" + escape( setString ) + "; path=/; domain=" + document.domain + ";"
		compareText = setString;
	}

	for (i = idx; i < 4; i++){
		html = "<span id=\"compModel0\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;</span> <IMG SRC=\"/web/images/common/compare/btn_x.gif\" ALT=\"x\">";
		obj = document.getElementById("compareBoxDown" + i);
		obj.innerHTML = html;

		obj = document.getElementById("compareBoxUpText" + i);
		obj.innerHTML = html;

		html = "<DL>";
		html += "<DT>&nbsp;";
		html += "<DD class=\"txt1\">&nbsp;";
		html += "<DD class=\"txt2\">&nbsp;";
		html += "<DD class=\"txt3\">&nbsp;";
		html += "</DL>";

		obj = document.getElementById("compareBoxUp" + i);
		obj.innerHTML = html;
	}
}

function f_deleteCompare(num){
	var compareProduct, arr1, i, setString, idx, arr2;

	compareProduct = compareText;

	idx = 1;
	setString = "";
	if (compareProduct != ""){
		arr1 = compareProduct.split("-&-");

		for (i = 0; i < arr1.length; i++){
			if(i != num){
				setString += arr1[i] + "-&-";
				arr2 = arr1[i].split("^^");

				document.frmCompare.goods[(idx -1)].value = arr2[0];
				idx++;
			}
		}
		if(setString == ""){
			setString = setString.substring(0, setString.length - 3);
		}
		//document.cookie = "compareProduct=" + escape( setString ) + "; path=/; domain=" + document.domain + ";"
		compareText = setString;
	}else{
		document.frmCompare.goods[0].value = "";
		document.frmCompare.goods[1].value = "";
		document.frmCompare.goods[2].value = "";
		//document.cookie = "compareProduct=; path=/; domain=" + document.domain + ";"
		compareText = "";
	}
	f_displayCompare();
}

function f_putCompare(arg1, arg2, arg3, arg4, arg5){
	productNO = arg1;
	productNM = arg2;
	productModel = arg3;
	productImg = arg4;
	productLink = arg5;
	isCompare = "compare";
	f_addProduct();
}

function f_compareAuto(){
	if(isCompare == ""){
		f_phoneCompareDown();
		window.clearInterval(actionUp);
	}
}


// Drag & Drop Start
function f_dragStart(obj, arg1, arg2, arg3, arg4, arg5, event){
	//var y, x;
	//var img, html, browser, sY;
	var html

	productNO = arg1;
	productNM = arg2;
	productModel = arg3;
	productImg = arg4;
	productLink = arg5;

	/*
	// after add program, firefox not support 08.12.30
	event = event ? event : window.event;

	y = event.y ? event.y : event.clientY;
	x = event.x ? event.x : event.clientX;


	browser = navigator.appName;
	if(browser.toLowerCase() == "netscape"){
		sY = self.pageYOffset;
	}else{
		sY = document.documentElement.scrollTop; 
	}
	y = y + sY;

	img = new Image();
	img.src = arg4;
	*/

	html = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"71\" height=\"102\">";
	html += "<tr>";
	html += "<td align=\"center\">";
	html += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	html += "<tr>";
	// ie 6 downloading issue 08.12.30
	//html += "<td background=\"" + arg4 + "\" width=\"71\" height=\"102\">&nbsp;";
	//html += "</td>";
	html += "<td>";
	html += "<img src=\"" + arg4 + "\"  width=\"71\" height=\"102\"/>";
	html += "</td>";
	html += "</tr>";
	html += "</table>";
	html += "</td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td align=\"center\"><b>" + arg3 + "</b></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td align=\"center\">" + arg2 + "</td>";
	html += "</tr>";
	html += "</table>";


	dragLayer = document.getElementById("dragLayer");
	dragLayer.innerHTML = html;
	dragYN = true;
	isCompare = "";
	f_phoneCompareUp();
}

document.documentElement.onmousemove = f_dragging;
document.documentElement.onmouseup = f_dragEnd;

function f_dragging(e){
	var y, x, browser, sY;

	if(dragYN == true){
		if(document.all)e = event;
		e = e ? e : window.event;

		y = e.y ? e.y : e.clientY;
		x = e.x ? e.x : e.clientX;

		browser = navigator.appName;
		if(browser.toLowerCase() == "netscape"){
			sY = self.pageYOffset;
		}else{
			sY = document.documentElement.scrollTop; 
		}
		y = y + sY;

		dragLayer = document.getElementById("dragLayer");
		dragLayer.style.top = (y - 125) + "px";
		dragLayer.style.left = (x -98) + "px";
		dragLayer.style.display = "block";
		document.documentElement.onselectstart = f_notSelect;
	}
}

function f_notSelect(){
	return false;
}

function f_dragEnd(event){
	event = event ? event : window.event;

	dragYN = false;
	dragLayer = document.getElementById("dragLayer");
	if(dragLayer != null){
		dragLayer.style.display = "none";
		document.documentElement.onselectstart = "";

		//firefox not support multiple events.
		if(((navigator.userAgent).toLowerCase()).indexOf("firefox") > 0){
			setTimeout("f_dragEndFireFox();", 2500);
		}else{
			f_addProduct();
		}
	}
}

function f_dragEndFireFox(){
	f_addProduct();
}
// Drag & Drop End

function flash(a,b,c,d) {
	var flash_tag = "";
	flash_tag = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	flash_tag +='WIDTH="'+a+'" HEIGHT="'+b+'"  id="'+d+'">';
	flash_tag +='<param name="movie" value="'+c+'">';
	flash_tag +='<param name="quality" value="high">';
	flash_tag +='<param name="wmode" value="transparent">';//頂岆灅鞁� 氚瓣步 韴獏 靹れ爼
	flash_tag +='<embed src="'+c+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+a+'" HEIGHT="'+b+'"></embed></object>'
	document.write(flash_tag);
}